package org.evolver.disser;

import org.apfloat.Apfloat;
import org.apfloat.ApfloatMath;
import org.evolver.disser.DoubleParameter;

public class InputVariables {
    public DoubleParameter  wg_b0;
    public DoubleParameter  wg_a0;
    public DoubleParameter  wg_alpha;
    public DoubleParameter  wg_q;

    public DoubleParameter  sm_b0;
    public DoubleParameter  sm_d0;
    public DoubleParameter  sm_alpha;

    public DoubleParameter  lambda;
    public DoubleParameter  t;
    public DoubleParameter  delta_l;
    public DoubleParameter  delta_xt;

    public DoubleParameter  epsMin;
    public DoubleParameter  epsMax;

    final static        int             CP         = 20;    // computation precision

    final static public DoubleParameter DP_ONE     = new DoubleParameter("ONE", "", 1.0, CP, 1);
    final static public DoubleParameter DP_TWO     = new DoubleParameter("TWO", "", 2.0, CP, 1);
    final static public DoubleParameter DP_PI      = new DoubleParameter("PI", "", ApfloatMath.pi(CP), CP, 1);
    final static public DoubleParameter DP_4_PI_SQ = new DoubleParameter("4_PI_SQ", "", DP_TWO.multiply(DP_TWO).multiply(DP_PI).multiply(DP_PI), CP, 8);

// These values are computed
    private DoubleParameter wg_at;          // width of a heated waveguide window
    private DoubleParameter wg_bt;          // height of a heated waveguide window
    private DoubleParameter sm_bt;          // height of a heated sample
    private DoubleParameter sm_dt;          // depth of a heated sample
    private DoubleParameter lambda_cr;
    private DoubleParameter lambda_g;
    private DoubleParameter one_over_lambda_cr_sq;
    private DoubleParameter one_over_lambda_g_sq;
    private DoubleParameter lambda_over_lambda_cr_sq;
    private DoubleParameter K;
    private DoubleParameter at_over_2bt;
    private DoubleParameter eq1_rhs_tg;

    public InputVariables() {
        wg_b0    = new DoubleParameter("Высота волновода", "мм", 32.0, CP, 2);
        wg_a0    = new DoubleParameter("Ширина волновода", "мм", 10.0, CP, 2);
        wg_alpha = new DoubleParameter("ЛКТР волновода", "1/град", 0.0, CP, 6);
        wg_q     = new DoubleParameter("Коэфф. затухания волновода", "", 0.000001, CP, 8);

        sm_b0    = new DoubleParameter("Высота образца", "мм", 9.99, CP, 2);
        sm_d0    = new DoubleParameter("Толщина образца", "мм", 50.0, CP, 2);
        sm_alpha = new DoubleParameter("ЛКТР образца", "1/град", 0.0, CP, 6);

        lambda   = new DoubleParameter("Длина волны генератора", "мм", 30.0, CP, 2);
        t        = new DoubleParameter("Температура", "град. C", 20.0, CP, 0);
        delta_l  = new DoubleParameter("Сдвиг минимума стоячей волны", "мм", 5.1, CP, 2);
        delta_xt = new DoubleParameter("Ширина двойного минимума", "мм", 2.1, CP, 2);

        epsMin   = new DoubleParameter("Мин. epsilon", "", 1.1, CP, 3);
        epsMax   = new DoubleParameter("Макс. epsilon", "", 25.0, CP, 3);

//      Additional parameters computed directly from input data
        wg_bt    = new DoubleParameter("Высота нагретого волновода", "мм", 32.0, CP, 2);
        wg_at    = new DoubleParameter("Ширина нагретого волновода", "мм", 10.0, CP, 2);
        sm_bt    = new DoubleParameter("Высота нагретого образца", "мм", 9.99, CP, 2);
        sm_dt    = new DoubleParameter("Толщина нагретого образца", "мм", 50.0, CP, 2);

        lambda_cr   = new DoubleParameter("Критическая длина волны", "мм", 30.0, CP, 2);
        lambda_g    = new DoubleParameter("Длина волны в волноводе", "мм", 30.0, CP, 2);

        one_over_lambda_cr_sq    = new DoubleParameter("one_over_lambda_cr_sq", "", 0.0, CP, 6);
        one_over_lambda_g_sq     = new DoubleParameter("one_over_lambda_g_sq", "", 0.0, CP, 6);
        lambda_over_lambda_cr_sq = new DoubleParameter("lambda_over_lambda_cr_sq", "", 0.0, CP, 6);
        K                        = new DoubleParameter("K", "", 0.0, CP, 6);
        at_over_2bt              = new DoubleParameter("at_over_2bt", "", 0.0, CP, 6);
        eq1_rhs_tg               = new DoubleParameter("eq1_rhs_tg", "", 0.0, CP, 6);
    }

    public String toString() {
        StringBuilder   sb = new StringBuilder();
        String          NEW_LINE = System.getProperty("line.separator");

        sb.append("Исходные данные:" + NEW_LINE);
        sb.append(wg_b0 + NEW_LINE);
        sb.append(wg_a0 + NEW_LINE);
        sb.append(wg_alpha + NEW_LINE);
        sb.append(wg_q + NEW_LINE);

        sb.append(sm_b0 + NEW_LINE);
        sb.append(sm_d0 + NEW_LINE);
        sb.append(sm_alpha + NEW_LINE);

        sb.append(lambda + NEW_LINE);
        sb.append(t + NEW_LINE);
        sb.append(delta_l + NEW_LINE);
        sb.append(delta_xt+ NEW_LINE);

        sb.append(epsMin + NEW_LINE);
        sb.append(epsMax + NEW_LINE);

        sb.append(NEW_LINE);
        sb.append("Вторичные данные:" + NEW_LINE);
        sb.append(wg_bt + NEW_LINE);
        sb.append(wg_at + NEW_LINE);
        sb.append(sm_bt + NEW_LINE);
        sb.append(sm_dt + NEW_LINE);
        
        sb.append(lambda_cr + NEW_LINE);
        sb.append(lambda_g + NEW_LINE);

        sb.append(NEW_LINE);
        sb.append("Вспомогательные данные:" + NEW_LINE);

        sb.append(one_over_lambda_cr_sq + NEW_LINE);
        sb.append(one_over_lambda_g_sq + NEW_LINE);
        sb.append(lambda_over_lambda_cr_sq + NEW_LINE);
        sb.append(K + NEW_LINE);
        sb.append(at_over_2bt + NEW_LINE);
        sb.append(eq1_rhs_tg + NEW_LINE);

        return sb.toString();
    }
}
